package com.tdkj.action.backstage.information;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.tdkj.action.BaseAction;
import com.tdkj.model.information.BeanBaseInfo;
import com.tdkj.model.information.BeanExpert;
import com.tdkj.service.information.IBeanExpertArticleService;
public class ExpertArticleAction  extends BaseAction{
	private Long expertId;
	private Long id;
	private String status;
	private BeanBaseInfo article=new BeanBaseInfo();
	private List<BeanBaseInfo> articles=new ArrayList<BeanBaseInfo>();
	private IBeanExpertArticleService articleService;
	private String[] ids;
	public String deleteAll() {
		if (null != ids) {
			for (String idtemp : ids) {
				this.getBaseService().delete(Long.parseLong(idtemp), BeanBaseInfo.class);
			}
		}
		return findAll();
	}
	public String[] getIds() {
		return ids;
	}

	public void setIds(String[] ids) {
		this.ids = ids;
	}
	public Long getExpertId() {
		return expertId;
	}

	public void setExpertId(Long expertId) {
		this.expertId = expertId;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public BeanBaseInfo getArticle() {
		return article;
	}

	public void setArticle(BeanBaseInfo article) {
		this.article = article;
	}

	public List<BeanBaseInfo> getArticles() {
		return articles;
	}

	public void setArticles(List<BeanBaseInfo> articles) {
		this.articles = articles;
	}

	public IBeanExpertArticleService getArticleService() {
		return articleService;
	}
	@Resource
	public void setArticleService(IBeanExpertArticleService articleService) {
		this.articleService = articleService;
	}

	//获取专家列表
	public String findAll(){
		Criteria criteria = this.createCriteria(BeanBaseInfo.class)
				.add(Restrictions.eq("expert", articleService.findById(this.getExpertId(), BeanExpert.class)))
				.add(Restrictions.eq("moduletype", "11"))
				.add(Restrictions.eq("columntype", "2"))
				.addOrder(Order.desc("createtime"));// 对状态进行排序
		this.queryByPage(criteria, "expertArticleAction!findAll.action", 10);
		return "findAll";
	}

	
	
	//编辑专家
	public String editArticle(){
//		BeanExpert bean=expertService.findById(this.getId(), BeanExpert.class);
//		bean=this.getExpert();
//		expertService.merge(bean);
		return findAll();
	}
	
	public String deleteArticle(){
//		expert.setId(this.getId());
//		expertService.delete(expert);
		return findAll();
	}
	
	//处理状态
	public String updateStatus(){
		//expertService.updateStatus(this.getId(),this.getStatus());
		return findAll();
	}
	
}
